home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Languguage OS 2
/
Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO
/
language
/
embedded
/
develop
/
libsrc11.arc
/
WRBYTEE.C
< prev
next >
Wrap
C/C++ Source or Header
|
1989-04-27
|
1KB
|
58 lines
/* wrbytee.c 4.7 */
/*F****************************************************************************
FUNCTION NAME: wrbytee
ACTION: Program a byte in EEPROM at the address provided. If
the address is -1, then the config register is programmed.
PARAMETERS:
addr: offset into EEPROM of location to be programmed.
If addr is -1, then the config register is programmed.
Otherwise, the value of a addr is restricted to
being from 0 to EEPROM size minus one.
data: value to burned into EEPROM.
RETURNS: (void)
******************************************************************************/
#define PROG_TIME 10 /* Programming delay time */
#define EROM_SIZE 512 /* Size of EEPROM */
#define PROG_CONFIG -1 /* indicator to program the config register */
#define ERASED 0xFF /* value read from EEPROM when it is erased */
#include <hc11/io.h>
#include <hc11/config.h>
#include <hc11/directives.h>
SMALL
void wrbytee(addr, data)
int addr; /* location to be programmed */
int data; /* value to be programmed */
{
if ((addr != PROG_CONFIG) & (EEPROM[addr&(EROM_SIZE-1)] != ERASED))
erbytee(addr); /* cannot erase Config register ! */
HC11.PPROG = EELAT;
if (addr == PROG_CONFIG)
HC11.CONFIG = data;
else
EEPROM[addr&(EROM_SIZE-1)] = data;
HC11.PPROG = EELAT | EEPGM;
/* delay for 10 milliseconds */
delay(PROG_TIME);
HC11.PPROG = EELAT;
HC11.PPROG = 0;
} /* end of wrbytee */